package com.zhuoyue.system.service.impl;

import java.util.List;

import com.zhuoyue.common.annotation.DataScope;
import com.zhuoyue.common.annotation.DataSource;

import com.zhuoyue.system.domain.po.TblGatewayPo;
import com.zhuoyue.system.domain.vo.TblGatewayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhuoyue.system.mapper.TblGatewayMapper;
import com.zhuoyue.system.service.ITblGatewayService;

import static com.zhuoyue.common.enums.DataSourceType.SLAVE;

/**
 * 网关Service业务层处理
 *
 * @author hewenze
 * @date 2020-08-07
 */
@Service
public class TblGatewayServiceImpl implements ITblGatewayService {
    @Autowired
    private TblGatewayMapper tblGatewayMapper;


    /**
     * 查询网关列表
     *
     * @param tblGatewayPo 网关
     * @return 网关
     */
    @DataScope(deptAlias = "s_d")
    @Override
    public List<TblGatewayVo> selectTblGatewayList(TblGatewayPo tblGatewayPo) {
        return tblGatewayMapper.selectTblGatewayList(tblGatewayPo);
    }

    @Override
    @DataSource(SLAVE)
    public int untieTblGatewayById(String id) {
        int i = tblGatewayMapper.untieTblGateway(id);
        return i;
    }

    @Override
    public TblGatewayVo selectById(String id) {
        return tblGatewayMapper.selectGatewayByGatewayId(id, null);
    }

    @Override
    public TblGatewayVo selectByMac(String mac) {
        return tblGatewayMapper.selectGatewayByGatewayId(null, mac);
    }


}
